VERSION 5.00
Object = "{831FDD16-0C5C-11D2-A9FC-0000F8754DA1}#2.1#0"; "mscomctl.OCX"
Begin VB.Form frmOrdenPac 
   Caption         =   "Ordenes de Trabajo"
   ClientHeight    =   10485
   ClientLeft      =   60
   ClientTop       =   435
   ClientWidth     =   11400
   LinkTopic       =   "Form1"
   ScaleHeight     =   10485
   ScaleWidth      =   11400
   StartUpPosition =   2  'CenterScreen
   WindowState     =   2  'Maximized
   Begin VB.TextBox Text1 
      BeginProperty Font 
         Name            =   "Arial"
         Size            =   12
         Charset         =   0
         Weight          =   700
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   405
      Left            =   1320
      Locked          =   -1  'True
      TabIndex        =   19
      Top             =   0
      Width           =   1575
   End
   Begin VB.TextBox Text2 
      Height          =   285
      Left            =   5040
      Locked          =   -1  'True
      TabIndex        =   18
      Top             =   0
      Width           =   1095
   End
   Begin VB.TextBox Text3 
      Height          =   285
      Left            =   7680
      Locked          =   -1  'True
      TabIndex        =   17
      Top             =   0
      Width           =   1095
   End
   Begin VB.ComboBox Combo1 
      Height          =   315
      Left            =   10680
      TabIndex        =   16
      Top             =   0
      Width           =   2175
   End
   Begin VB.TextBox Text4 
      Height          =   285
      Left            =   2280
      MultiLine       =   -1  'True
      ScrollBars      =   2  'Vertical
      TabIndex        =   15
      Top             =   480
      Width           =   10575
   End
   Begin VB.CommandButton COMANDO 
      Caption         =   "Cancelar Todas"
      BeginProperty Font 
         Name            =   "Eras Bold ITC"
         Size            =   12
         Charset         =   0
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   400
      Left            =   7080
      TabIndex        =   13
      Top             =   5400
      Width           =   2235
   End
   Begin VB.CommandButton Command1 
      Caption         =   "Nuevo"
      BeginProperty Font 
         Name            =   "Eras Bold ITC"
         Size            =   12
         Charset         =   0
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   400
      Left            =   2760
      TabIndex        =   0
      Top             =   9900
      Width           =   1300
   End
   Begin VB.CommandButton Command2 
      Caption         =   "Guardar"
      BeginProperty Font 
         Name            =   "Eras Bold ITC"
         Size            =   12
         Charset         =   0
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   400
      Left            =   4200
      TabIndex        =   12
      Top             =   9900
      Width           =   1300
   End
   Begin VB.CommandButton Command3 
      Caption         =   "Cancelar"
      BeginProperty Font 
         Name            =   "Arial"
         Size            =   12
         Charset         =   0
         Weight          =   700
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   400
      Left            =   4200
      TabIndex        =   11
      Top             =   9900
      Visible         =   0   'False
      Width           =   1300
   End
   Begin VB.CommandButton Command4 
      Caption         =   "Modificar"
      BeginProperty Font 
         Name            =   "Eras Bold ITC"
         Size            =   12
         Charset         =   0
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   400
      Left            =   5640
      TabIndex        =   10
      Top             =   9900
      Width           =   1425
   End
   Begin VB.CommandButton Command5 
      Caption         =   "Eliminar"
      BeginProperty Font 
         Name            =   "Eras Bold ITC"
         Size            =   12
         Charset         =   0
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   400
      Left            =   8640
      TabIndex        =   9
      Top             =   9900
      Width           =   1300
   End
   Begin VB.CommandButton Command6 
      Caption         =   "Salir"
      BeginProperty Font 
         Name            =   "Eras Bold ITC"
         Size            =   12
         Charset         =   0
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   400
      Left            =   10080
      TabIndex        =   8
      Top             =   9900
      Width           =   975
   End
   Begin VB.CommandButton Command7 
      Caption         =   "Aceptar Todas"
      BeginProperty Font 
         Name            =   "Eras Bold ITC"
         Size            =   12
         Charset         =   0
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   400
      Left            =   6840
      TabIndex        =   7
      Top             =   960
      Width           =   2235
   End
   Begin VB.CommandButton Command8 
      Caption         =   "|<"
      BeginProperty Font 
         Name            =   "Arial"
         Size            =   15.75
         Charset         =   0
         Weight          =   700
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   400
      Left            =   11400
      TabIndex        =   5
      Top             =   9900
      Width           =   450
   End
   Begin VB.CommandButton Command9 
      Caption         =   "<"
      BeginProperty Font 
         Name            =   "Arial"
         Size            =   15.75
         Charset         =   0
         Weight          =   700
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   400
      Left            =   11880
      TabIndex        =   4
      Top             =   9900
      Width           =   450
   End
   Begin VB.CommandButton Command10 
      Caption         =   ">"
      BeginProperty Font 
         Name            =   "Arial"
         Size            =   15.75
         Charset         =   0
         Weight          =   700
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   400
      Left            =   12480
      TabIndex        =   3
      Top             =   9900
      Width           =   450
   End
   Begin VB.CommandButton Command11 
      Caption         =   ">|"
      BeginProperty Font 
         Name            =   "Arial"
         Size            =   15.75
         Charset         =   0
         Weight          =   700
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   400
      Left            =   12960
      TabIndex        =   2
      Top             =   9900
      Width           =   450
   End
   Begin VB.CommandButton Command12 
      Caption         =   "Imprimir"
      BeginProperty Font 
         Name            =   "Eras Bold ITC"
         Size            =   12
         Charset         =   0
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   525
      Left            =   7200
      TabIndex        =   1
      Top             =   9840
      Width           =   1300
   End
   Begin MSComctlLib.ListView ListView2 
      Height          =   3780
      Left            =   480
      TabIndex        =   6
      Top             =   5880
      Width           =   14535
      _ExtentX        =   25638
      _ExtentY        =   6668
      View            =   3
      LabelWrap       =   -1  'True
      HideSelection   =   -1  'True
      FlatScrollBar   =   -1  'True
      FullRowSelect   =   -1  'True
      GridLines       =   -1  'True
      HotTracking     =   -1  'True
      TextBackground  =   -1  'True
      _Version        =   393217
      ForeColor       =   -2147483640
      BackColor       =   16777215
      BorderStyle     =   1
      Appearance      =   1
      BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
         Name            =   "Verdana"
         Size            =   8.25
         Charset         =   0
         Weight          =   700
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      NumItems        =   7
      BeginProperty ColumnHeader(1) {BDD1F052-858B-11D1-B16A-00C0F0283628} 
         Text            =   "Paciente"
         Object.Width           =   1764
      EndProperty
      BeginProperty ColumnHeader(2) {BDD1F052-858B-11D1-B16A-00C0F0283628} 
         SubItemIndex    =   1
         Text            =   "Pedido"
         Object.Width           =   1764
      EndProperty
      BeginProperty ColumnHeader(3) {BDD1F052-858B-11D1-B16A-00C0F0283628} 
         SubItemIndex    =   2
         Text            =   "Fecha"
         Object.Width           =   2540
      EndProperty
      BeginProperty ColumnHeader(4) {BDD1F052-858B-11D1-B16A-00C0F0283628} 
         SubItemIndex    =   3
         Text            =   "Paciente"
         Object.Width           =   8290
      EndProperty
      BeginProperty ColumnHeader(5) {BDD1F052-858B-11D1-B16A-00C0F0283628} 
         SubItemIndex    =   4
         Text            =   "Edad"
         Object.Width           =   2540
      EndProperty
      BeginProperty ColumnHeader(6) {BDD1F052-858B-11D1-B16A-00C0F0283628} 
         SubItemIndex    =   5
         Text            =   "Examen"
         Object.Width           =   8290
      EndProperty
      BeginProperty ColumnHeader(7) {BDD1F052-858B-11D1-B16A-00C0F0283628} 
         SubItemIndex    =   6
         Text            =   "cod_detalle"
         Object.Width           =   0
      EndProperty
   End
   Begin MSComctlLib.ListView ListView1 
      Height          =   3780
      Left            =   360
      TabIndex        =   14
      Top             =   1440
      Width           =   14535
      _ExtentX        =   25638
      _ExtentY        =   6668
      View            =   3
      LabelWrap       =   -1  'True
      HideSelection   =   -1  'True
      FlatScrollBar   =   -1  'True
      FullRowSelect   =   -1  'True
      GridLines       =   -1  'True
      HotTracking     =   -1  'True
      TextBackground  =   -1  'True
      _Version        =   393217
      ForeColor       =   -2147483640
      BackColor       =   16777215
      BorderStyle     =   1
      Appearance      =   1
      BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
         Name            =   "Verdana"
         Size            =   8.25
         Charset         =   0
         Weight          =   700
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      NumItems        =   7
      BeginProperty ColumnHeader(1) {BDD1F052-858B-11D1-B16A-00C0F0283628} 
         Text            =   "Paciente"
         Object.Width           =   1764
      EndProperty
      BeginProperty ColumnHeader(2) {BDD1F052-858B-11D1-B16A-00C0F0283628} 
         SubItemIndex    =   1
         Text            =   "Pedido"
         Object.Width           =   1764
      EndProperty
      BeginProperty ColumnHeader(3) {BDD1F052-858B-11D1-B16A-00C0F0283628} 
         SubItemIndex    =   2
         Text            =   "Fecha"
         Object.Width           =   2540
      EndProperty
      BeginProperty ColumnHeader(4) {BDD1F052-858B-11D1-B16A-00C0F0283628} 
         SubItemIndex    =   3
         Text            =   "Paciente"
         Object.Width           =   8290
      EndProperty
      BeginProperty ColumnHeader(5) {BDD1F052-858B-11D1-B16A-00C0F0283628} 
         SubItemIndex    =   4
         Text            =   "Edad"
         Object.Width           =   2540
      EndProperty
      BeginProperty ColumnHeader(6) {BDD1F052-858B-11D1-B16A-00C0F0283628} 
         SubItemIndex    =   5
         Text            =   "Examen"
         Object.Width           =   8290
      EndProperty
      BeginProperty ColumnHeader(7) {BDD1F052-858B-11D1-B16A-00C0F0283628} 
         SubItemIndex    =   6
         Text            =   "cod_detalle"
         Object.Width           =   0
      EndProperty
   End
   Begin VB.Label SkinLabel2 
      Caption         =   "Fecha:"
      BeginProperty Font 
         Name            =   "MS Sans Serif"
         Size            =   9.75
         Charset         =   0
         Weight          =   700
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   255
      Left            =   3600
      TabIndex        =   20
      Top             =   0
      Width           =   1095
   End
   Begin VB.Label SkinLabel3 
      Caption         =   "Hora:"
      BeginProperty Font 
         Name            =   "MS Sans Serif"
         Size            =   9.75
         Charset         =   0
         Weight          =   700
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   255
      Left            =   6720
      TabIndex        =   21
      Top             =   0
      Width           =   855
   End
   Begin VB.Label SkinLabel4 
      Caption         =   "Bioanalista:"
      BeginProperty Font 
         Name            =   "MS Sans Serif"
         Size            =   9.75
         Charset         =   0
         Weight          =   700
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   255
      Left            =   9240
      TabIndex        =   22
      Top             =   0
      Width           =   1455
   End
   Begin VB.Label SkinLabel5 
      Caption         =   "Observaciones:"
      BeginProperty Font 
         Name            =   "MS Sans Serif"
         Size            =   9.75
         Charset         =   0
         Weight          =   700
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   375
      Left            =   480
      TabIndex        =   23
      Top             =   480
      Width           =   1935
   End
   Begin VB.Label SkinLabel6 
      Caption         =   "Ordenes por asignar:"
      BeginProperty Font 
         Name            =   "MS Sans Serif"
         Size            =   9.75
         Charset         =   0
         Weight          =   700
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   375
      Left            =   360
      TabIndex        =   24
      Top             =   1080
      Width           =   3735
   End
   Begin VB.Label SkinLabel7 
      Caption         =   "Ordenes asignadas:"
      BeginProperty Font 
         Name            =   "MS Sans Serif"
         Size            =   9.75
         Charset         =   0
         Weight          =   700
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   375
      Left            =   480
      TabIndex        =   25
      Top             =   5520
      Width           =   3975
   End
   Begin VB.Label SkinLabel1 
      Caption         =   "Orden:"
      BeginProperty Font 
         Name            =   "MS Sans Serif"
         Size            =   9.75
         Charset         =   0
         Weight          =   700
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   255
      Left            =   120
      TabIndex        =   26
      Top             =   120
      Width           =   975
   End
End
Attribute VB_Name = "frmOrdenPac"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Dim tabla As DAO.Recordset
Sub Botones(es As Integer)
    If es = 1 Then
        Command1.Enabled = True
        Command2.Enabled = False
        Command4.Enabled = False
        Command5.Enabled = False
    End If
    If es = 2 Then
        Command1.Enabled = False
        Command2.Enabled = True
        Command4.Enabled = False
        Command5.Enabled = False
    End If
    If es = 3 Then
        Command1.Enabled = True
        Command2.Enabled = False
        Command4.Enabled = True
        Command5.Enabled = True
    End If
End Sub
Sub Limpiar()
    Text1.Text = ""
    Text2.Text = ""
    Text3.Text = ""
    Text4.Text = ""
    Combo1.Text = ""
'    Combo2.Text = ""
    ListView1.ListItems.Clear
    ListView2.ListItems.Clear
End Sub
Sub Cancelar()
    Limpiar
    Bloquear False
    Botones 1
End Sub
Sub Bloquear(st As Boolean)
    Text1.Enabled = st
    Text2.Enabled = st
    Text3.Enabled = st
    Text4.Enabled = st
    Combo1.Enabled = st
'    Combo2.Enabled = St
    COMANDO.Enabled = st
    Command7.Enabled = st
    ListView1.Enabled = st
    ListView2.Enabled = st
End Sub
Function DETALLESel(LV As ListView)
On Error Resume Next
    DETALLESel = LV.SelectedItem.ListSubItems(1)
End Function

Sub Mostrar_Detalle1()
    On Error Resume Next
    Dim t As DAO.Recordset
    Dim subelemento As ListItem
    Set t = Base.OpenRecordset("select *from ConsultaOrdenesPac where cod_ordenPAC=0 order by cod_pedido")
    ListView1.ListItems.Clear
    While Not t.EOF
        Set subelemento = ListView1.ListItems.Add(, , t("PACIENTENRO"))
        subelemento.SubItems(1) = t("COD_PEDIDO")
        subelemento.SubItems(2) = t("FECHA")
        subelemento.SubItems(3) = t("NOMBRES")
        subelemento.SubItems(4) = "" & t("APELLIDOS") & t("DA")
        'subelemento.SubItems(5) = t("DESCRIPCION")
        'subelemento.SubItems(6) = t("Cod_detalle")
        t.MoveNext
    Wend
End Sub
Sub Mostrar_Detalle2()
'On Error GoTo sal
    Dim t As DAO.Recordset
    Dim subelemento As ListItem
    Set t = Base.OpenRecordset("select *from ConsultaOrdenesPac where cod_ordenPac=" & Text1.Text & " order by COD_PEDIDO")
    ListView2.ListItems.Clear
    While Not t.EOF
        Set subelemento = ListView2.ListItems.Add(, , t("PACIENTENRO"))
        subelemento.SubItems(1) = t("COD_PEDIDO")
        If Not IsNull(t("FECHA")) Then subelemento.SubItems(2) = t("FECHA")
        subelemento.SubItems(3) = t("NOMBRES")
        subelemento.SubItems(4) = t("APELLIDOS") & t("DA")
        'subelemento.SubItems(5) = t("DESCRIPCION")
        'subelemento.SubItems(6) = t("Cod_detalle")
        t.MoveNext
    Wend
sal:
End Sub

Private Sub COMANDO_Click()
    For i = 1 To ListView2.ListItems.Count
        x = val(ListView2.ListItems.Item(i).SubItems(1))
        Base.Execute "update pedido set cod_ordenPAC=0 where cod_Pedido=" & x
    Next
    Mostrar_Detalle1
    Mostrar_Detalle2

End Sub


Private Sub Command1_Click()
    Cancelar
    Text1.Text = AutoNumero("ort_registro", "OrdentrabajoPC")
    Text2.Text = Date
    Text3.Text = Time
    Bloquear True
    Combo1.SetFocus
    Botones 2
    Mostrar_Detalle1
    Mostrar_Detalle2

End Sub
Private Sub Command10_Click()
Command10.Enabled = False
DoEvents
On Error Resume Next
    tabla.MoveNext
    mostrar
    Mostrar_Detalle1
    Mostrar_Detalle2
Command10.Enabled = True

End Sub
Private Sub Command11_Click()
On Error Resume Next
    tabla.MoveLast
    mostrar
    Mostrar_Detalle1
    Mostrar_Detalle2
End Sub

Private Sub Command12_Click()
    If Text1.Text = "" Then Exit Sub
    f = "{OrdentrabajoPC.ORT_Registro}=" & Text1.Text
    ''Set 'FrmReporte = Nothing
    'Load 'FrmReporte
    'Set 'FrmReporte.Report = New rptOrdenPac
    'FrmReporte.Report.RecordSelectionFormula = f
    'FrmReporte.Accion = "p"
    'FrmReporte.PrintReport
    'FrmReporte.Show vbModal
    Set tabla = Base.OpenRecordset("OrdentrabajoPC")
End Sub

Private Sub Command2_Click()
  Auditar "Guardar", "Ordenes", Text1.Text
  If ListView2.ListItems.Count <= 0 Then Exit Sub
Dim t As DAO.Recordset
Set t = Base.OpenRecordset("select *from OrdentrabajoPC where Ort_Registro=" & Text1.Text & "")
    If Not t.EOF Then
        tabla.Edit
    Else
        tabla.AddNew
    End If
        Guardar
    tabla.Update
    Bloquear False
    Botones 1
End Sub
Private Sub Command3_Click()
    Cancelar
End Sub
Private Sub Command4_Click()
    Bloquear False
    Text4.Enabled = True
    Combo1.Enabled = True
    ListView1.Enabled = True
    ListView2.Enabled = True
    Command7.Enabled = True
    COMANDO.Enabled = True
    Botones 3
End Sub

Private Sub Command5_Click()
    If MsgBox("Esta Seguro de que desea eliminar ", vbYesNo) = vbYes Then
        tabla.Delete
        Cancelar
    End If
End Sub

Private Sub Command6_Click()
    Unload Me
End Sub
Private Sub Command7_Click()
    For i = 1 To ListView1.ListItems.Count
        x = ListView1.ListItems.Item(i).SubItems(1)
        Base.Execute "update Pedido set cod_ordenPAC=" & Text1.Text & " where cod_Pedido=" & x
    Next
    Mostrar_Detalle1
    Mostrar_Detalle2
End Sub
Private Sub Command8_Click()
On Error Resume Next
    tabla.MoveFirst
    mostrar
    Mostrar_Detalle1
    Mostrar_Detalle2
End Sub
Private Sub Command9_Click()
Command9.Enabled = False
DoEvents
On Error Resume Next
    tabla.MovePrevious
    mostrar
    Mostrar_Detalle1
    Mostrar_Detalle2
Command9.Enabled = True

End Sub

Private Sub Form_Load()
    titulo2 "ordenes de trabajo"
    Me.Caption = titulo2("Ordenes por Paciente")
    'LlenarCombo Combo2, "select Descripcion from grupo"
    Cancelar
    On Error Resume Next
    Set tabla = Base.OpenRecordset("OrdentrabajoPC")
    tabla.MoveLast
    mostrar
'    Mostrar_Detalle1
    Mostrar_Detalle2
    LlenarCombo Combo1, "select nombres from bioanalistas"
End Sub


Private Sub ListView1_Click()
On Error Resume Next
    x = DETALLESel(ListView1)
    Base.Execute "update Pedido set cod_ordenPAC=" & Text1.Text & " where cod_Pedido=" & x
    Mostrar_Detalle1
    Mostrar_Detalle2
    
End Sub

Private Sub ListView2_Click()
On Error Resume Next
    x = DETALLESel(ListView2)
    Base.Execute "update Pedido set cod_ordenPAC=0 where cod_Pedido=" & x
    Mostrar_Detalle1
    Mostrar_Detalle2
End Sub
Sub mostrar()
    Limpiar
    Text1.Text = tabla(0)
    Text2.Text = tabla(1)
    Text3.Text = tabla(2)
    Combo1.Text = tabla(3)
    Text4.Text = tabla(4)
    Combo2.Text = CualDesGrupo(tabla(5))
    Botones 3
End Sub
Sub Guardar()
On Error Resume Next
    tabla(0) = Text1.Text
    tabla(1) = Text2.Text
    tabla(2) = Text3.Text
    tabla(3) = Combo1.Text
    tabla(4) = Text4.Text
    tabla(5) = CualGrupo(Combo2.Text)
End Sub


